#
# Copyright (c) CERN 2013-2015
#
# Copyright (c) Members of the EMI Collaboration. 2010-2013
#  See  http://www.eu-emi.eu/partners for details on the copyright
#  holders.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

cmake_minimum_required(VERSION 2.8)

find_package(ActiveMQcpp 3.2.0 REQUIRED)
find_package (Boost COMPONENTS filesystem thread system)
find_package (APR)

include_directories (${ACTIVEMQCPP_INCLUDE_DIR})
include_directories (${APR_INCLUDE_DIR})

# Disable "-Wdeprecated-declarations" warning generated by ActiveMQcpp library
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")

# libfts_msg_ifce
set(fts_msg_ifce_SOURCES
    msg-ifce.cpp
)

add_library(fts_msg_ifce SHARED ${fts_msg_ifce_SOURCES})
target_link_libraries(fts_msg_ifce
    fts_common
)
set_target_properties(fts_msg_ifce PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/src/monitoring
    VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
    SOVERSION ${VERSION_MAJOR}
    CLEAN_DIRECT_OUTPUT 1
)

# fts_msg_bulk binary
set(fts_msg_bulk_SOURCES
    msg-bulk-send.cpp
    MsgPipe.cpp
    MsgProducer.cpp
        BrokerConfig.cpp
)

add_executable(fts_msg_bulk ${fts_msg_bulk_SOURCES})
target_link_libraries(fts_msg_bulk
    ${ACTIVEMQCPP_LIBRARIES}
    fts_common
    fts_config
	fts_msg_bus
    rt
    ${Boost_LIBRARIES}
)

# Artifacts
install(TARGETS fts_msg_bulk
	RUNTIME DESTINATION ${SBIN_INSTALL_DIR}
)

install(TARGETS fts_msg_ifce
	RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
	LIBRARY DESTINATION ${LIB_INSTALL_DIR}
)
